import { Body, Controller, Get, Inject, Post, Query } from "@nestjs/common";
import { ApiOperation, ApiTags } from "@nestjs/swagger";
import { query } from "express";
import { PageQuery } from "src/common/page/PageQuery";
import { PageResult } from "src/common/page/PageResult";
import { Result } from "src/common/Result";
import { GoodsDto } from "src/dto/GoodsDto";
import { GoodsPriceService } from "src/service/GoodsPriceService";

@ApiTags("商品价格模块")
@Controller("/goodsPrice")
export class GoodsPriceController {

    @Inject()
    private goodsPriceService: GoodsPriceService;

    /**
     * 商品价格列表查询
     * @param dto 
     */
    @ApiOperation({summary: "商品价格列表查询"})
    @Post("/selectGoodsPrice")
    async selectGoodsPrice(@Body() query: PageQuery<GoodsDto>) {
        let data = await this.goodsPriceService.selectGoodsPrice(query);
        return Result.success("成功", PageResult.of(data));
    }
    
    /**
     * 单位价格
     * @param query 
     * @returns 
     */
    @ApiOperation({summary: "单位价格"})
    @Get("/selectUnitPrice")
    async selectUnitPrice(@Query() query:GoodsDto) {
        let data = await this.goodsPriceService.selectUnitPrice(query);
        return Result.success("成功!", data);
    }
}